<template>
	<view>
		<Header :title="cont+'详情'"></Header>
		<view class="top_img">
			<image :src="mood.imgUrl" mode="aspectFill" style="width: 100%;height: 100%;"></image>
		</view>
		<view class="canshu_box">
			<view class="canshu_boxTilte">蜂箱参数</view>
			<view class="" style="height: 30rpx;"></view>
			<view class="canshu_zi">
				<span>饲料费用/月：</span>
				<span style="color: red;">{{mood.rearMonthMoney}}</span>
			</view>
			<view class="canshu_zi">
				<span>最低产出/月：</span>
				<span style="color: red;">{{mood.minOutput}}</span>
			</view>
			<view class="canshu_zi">
				<span>最低{{titleKey}}月数：</span>
				<span style="color: red;">{{mood.minMonth}}</span>
			</view>
		</view>
		<view class="" style="height: 50rpx;"></view>
		<view class="canshu_box">
			<view class="canshu_boxTilte">转赠信息</view>
			<view class="" style="height: 30rpx;"></view>
			<view class="canshu_zi">
				<span>转赠人：</span>
				<span style="color: red;">{{mood.presentedName}}</span>
			</view>
			<view class="canshu_zi">
				<span>转赠时间：</span>
				<span style="color: red;">{{mood.presentedTime}}</span>
			</view>
			<view class="canshu_zi">
				<span>转赠状态：</span>
				<span style="color: red;" v-if="mood.state==1">已接收</span>
				<span style="color: red;" v-if="mood.state==2">已拒绝</span>
				<span style="color: red;" v-if="mood.state==0">待接收</span>
			</view>
		</view>
		<view class="" style="height: 50rpx;"></view>
		<view class="btn_flx" v-if="mood.state==0 & cont!='转赠'">
			<view class="jueBtn" @click="subitm(2)">拒绝</view>
			<view style="width: 30rpx;"></view>
			<view class="jeshouBtn" @click="subitm(1)">接受</view>
		</view>
	</view>
</template>

<script>
	import Header from '@/components/header/header.vue'
	export default {
		components: {
			Header
		},
		data() {
			return {
				cont: '转赠',
				id: '',
				mood: null,
				titleKey:uni.getStorageSync('titleKey')
			}
		},
		onLoad(e) {
			this.id = e.id
			this.cont = e.cont
			this.cread()
		},
		methods: {
			//是否接受转赠
			async subitm(e){
				let that = this 
				let res = await this.$api.request('manage/presented/client/update','post',{state:e,id:this.id})
				if(res.code==200){
					uni.showToast({
						title:'修改成功',
						icon:'none'
					})
					setTimeout(()=>{that.cread()},500)
				}
			},
			
			async cread() {
				let res
				if (this.cont == '转赠') {
					//转赠列表
					res = await this.$api.request('manage/presented/client/details/' + this.id)
				} else {
					//被转赠列表
					res = await this.$api.request('manage/presented/client/byDetails/' + this.id)
				}
				this.mood = res.data
			}
		}
	}
</script>

<style scoped>
	.btn_flx {
		display: flex;
		justify-content: center;
	}

	.jueBtn {
		width: 260rpx;
		height: 80rpx;
		background-color: #757575;
		color: #fff;
		font-size: 34rpx;
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
	}

	.jeshouBtn {
		width: 260rpx;
		height: 80rpx;
		background-color: #E8220F;
		color: #fff;
		font-size: 34rpx;
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
	}

	.canshu_zi {
		font-size: 30rpx;
		color: #999999;
		margin-top: 15rpx;
	}

	.canshu_boxTilte {
		font-size: 36rpx;
		color: #333333;
		margin-left: 32rpx;
		padding-top: 30rpx;
	}

	.top_img {
		width: 750rpx;
		height: 750rpx;
		background-color: aqua;
	}

	.canshu_box {
		width: 710rpx;
		margin-left: 20rpx;
		border-radius: 10rpx;
		background-color: #fff;
		padding-bottom: 30rpx;
	}
</style>